<template>
  <div class="goods-comment-image">
    <div class="list">
      <a
       href="javascript:;"
       v-for="url in pictureList"
       :key="url"
       @click="currentImage=url"
      ><img :src="url" alt=""></a>
    </div>
    <div class="preview" v-if="currentImage">
      <img :src="currentImage" alt="">
      <i @click="currentImage=null" class="iconfont icon-close-new"></i>
    </div>
  </div>
</template>

<script>
import { ref } from '@vue/reactivity'
export default {
  name: 'GoodsCommentPicture',
  props: {
    pictureList: {
      type: Array,
      default: () => []
    }
  },
  setup () {
    // 点击后记录当前点击的图片
    const currentImage = ref(null)
    return { currentImage }
  }
}
</script>

<style lang="less" scoped>
.goods-comment-image{
  .list{
    display: flex;
    margin-top: 10px;
    flex-wrap: wrap;
    a{
      width: 120px;
      height: 120px;
      border: 1px solid #e4e4e4;
      margin-right: 20px;
      margin-bottom: 10px;
      img{
        width: 100%;
        height: 100%;
        object-fit: contain;
      }
      &:active{
        border-color:@xtxColor;
      }
      &:hover{
        border-color:@xtxColor;
      }
    }
  }
  .preview{
    width: 480px;
    height: 480px;
    border: 1px solid #e4e4e4;
    background: #f8f8f8;
    margin-bottom: 20px;
    position: relative;
    img{
      width: 100%;
      height: 100%;
      object-fit: contain;
    }
    i{
      position: absolute;
      top: 0;
      right: 0;
      width: 30px;
      height: 30px;
      background-color: rgba(0,0,0,.2);
      color: #fff;
      text-align: center;
      line-height: 30px;
    }
  }
}
</style>
